%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plots Figures A.16
%
% need to run Stata Code MainRun.do first       
%
% Cloyne, Dimsdale and Hürtgen (2024) 								
%	"Are Tax Cuts Contractionary at the Zero Lower Bound? Evidence from a Century of Data"  	  		
%																			
% James Cloyne, Nicholas Dimsdale and Patrick Hürtgen, 2024
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all
close all
clc


OPTIONS.ShadedBands=1;

%% Gov Spending away from ZLB

f1  = fullfile('..\StataOutput\StateDep\Figure8aand16a\','DataIRF_S_govCETDToTax_smoothed_s_lnRealExpCurrent_smoothed.xlsx');

IRFa = xlsread(f1);

r_color = 235;
b_color = 235;
g_color = 255

xmin=0;
xmax=13;
stepsize=1;
Sdep=0;
OPTIONS.H=xmax;
IRFa=IRFa(1:xmax,:);

r_color = 235;
b_color = 235;
g_color = 255;

myplot=figure(1);

if OPTIONS.ShadedBands==0
    lb68=plot(xmin:xmax-1,IRFa(:,3+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    ub68=plot(xmin:xmax-1,IRFa(:,4+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    lb95=plot(xmin:xmax-1,IRFa(:,5+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
    ub95=plot(xmin:xmax-1,IRFa(:,6+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
elseif OPTIONS.ShadedBands==1
    shadedplot(xmin:xmax-1,IRFa(:,3+Sdep)',IRFa(:,4+Sdep)',[r_color/255 b_color/255 g_color/255],[r_color/255 b_color/255 g_color/255]); hold on;
    plot(xmin:xmax-1,IRFa(:,5+Sdep),'b','MarkerSize',5); hold on;
    plot(xmin:xmax-1,IRFa(:,6+Sdep),'b','MarkerSize',5); hold on;
end

a=plot(xmin:xmax-1,IRFa(:,2+Sdep), 'b-o','LineWidth',2.5,'MarkerSize',8);hold on

plot([min(xlim()),max(xlim())],[0,0], 'k','LineWidth',0.25);
set(gca,'TickDir','in'); 
xlabel('Quarters')
box off; grid off
set(gca,'XLIM', [-inf inf], 'gridlinestyle', '-.', 'gridalpha', 0.5, 'FontSize',16)
set(gca,'XLIM', [xmin xmax-1]);
set(gca,'YLIM', [-6 12]);
set(gca,'XTick',[xmin:stepsize:xmax-1]);
yticks([-6 -4 -2 0 2 4 6 8 10 12])
grid off
myplot.PaperPositionMode = 'manual';
set(myplot,'Position',[50 50 1200 800]);
orient(myplot,'landscape')

saveas(myplot, 'FigureA16a', 'pdf')
saveas(myplot, 'FigureA16a', 'epsc')

%% Deficit away from ZLB Regime

f1  = fullfile('..\StataOutput\StateDep\Figure8band16b\','DataIRF_S_DefToGDPToTax_smoothed_s_DefToGDP_smoothed.xlsx');

IRFa = xlsread(f1);  
IRFa = -IRFa; % take the negative of the IRF

xmin=0;
xmax=13;
stepsize=1;
Sdep=0;
OPTIONS.H=xmax;
IRFa=IRFa(1:xmax,:);

r_color = 235;
b_color = 235;
g_color = 255;

myplot=figure(2);

if OPTIONS.ShadedBands==0
    lb68=plot(xmin:xmax-1,IRFa(:,3+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    ub68=plot(xmin:xmax-1,IRFa(:,4+Sdep), 'k:','LineWidth',1,'MarkerSize',5);hold on
    lb95=plot(xmin:xmax-1,IRFa(:,5+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
    ub95=plot(xmin:xmax-1,IRFa(:,6+Sdep), 'k--','LineWidth',1,'MarkerSize',5);hold on
elseif OPTIONS.ShadedBands==1
    shadedplot(xmin:xmax-1,IRFa(:,3+Sdep)',IRFa(:,4+Sdep)',[r_color/255 b_color/255 g_color/255],[r_color/255 b_color/255 g_color/255]); hold on;
    plot(xmin:xmax-1,IRFa(:,5+Sdep),'b','MarkerSize',5); hold on;
    plot(xmin:xmax-1,IRFa(:,6+Sdep),'b','MarkerSize',5); hold on;
end

a=plot(xmin:xmax-1,IRFa(:,2+Sdep), 'b-o','LineWidth',2.5,'MarkerSize',8);hold on

plot([min(xlim()),max(xlim())],[0,0], 'k','LineWidth',0.25);
set(gca,'TickDir','in'); 
xlabel('Quarters');
box off; grid off
set(gca,'XLIM', [-inf inf], 'gridlinestyle', '-.', 'gridalpha', 0.5, 'FontSize',16)
set(gca,'XLIM', [xmin xmax-1]);
set(gca,'YLIM', [-2 3]);
set(gca,'XTick',[xmin:stepsize:xmax-1]);
yticks([-2 -1 0 1  2 3])
grid off
myplot.PaperPositionMode = 'manual';
set(myplot,'Position',[50 50 1200 800]);
orient(myplot,'landscape')

saveas(myplot, 'FigureA16b', 'pdf')
saveas(myplot, 'FigureA16b', 'epsc')